//格式化时间
//dateTime：时间戳
function getFormtTime(dateTime,flag) {
    if(dateTime != null ) {
        //若传入的dateTime为字符串类型，需要进行转换成数值，若不是无需下面注释代码
        var time = parseInt(dateTime)
        var date = new Date(time);
        //获取年份
        var YY = date.getFullYear();
        //获取月份
        var MM = (date.getMonth() + 1 < 10 ? '0'+(date.getMonth() + 1) : date.getMonth() + 1);
        //获取日期
        var DD = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate());
        if(flag) { //flag为true，显示时分秒格式
            //获取小时
            var hh = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours());
            //获取分
            var mm = (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes());
            ///获取秒
            var ss = (date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds());
            //返回时间格式： 2020-11-09 13:14:52
            return YY + '-' + MM + '-' + DD + ' ' + hh + ':' + mm + ':' + ss;
        } else {
            //返回时间格式： 2020-11-09
            return YY + '-' + MM + '-' + DD;
        }
    } else {
        return "";
    }
}
$.ajax({
    type: "post",
    url: "/orde/ordeView",
    data: {},
    dataType: "json",
    success: function (r) {
        if (r != "false") {
            var n=""
            if (r.status=="0"){
                n="未审核"
            }else if(r.status=="1"){
                n="审核中"
            }else if(r.status=="2"){
                n="审核通过"
            }else if(r.status=="3"){
                n="审核不通过"
            }
            var u="<li>\n" +
                "      <label>订单编号</label>\n" +
                "      <cite>"+r.orderid+"</cite>\n" +
                "    </li>\n" +
                "    <li>\n" +
                "      <label>客户姓名</label>\n" +
                "      <cite><a href='/market/queryOneCustom/"+r.customid+"' title=\"点击查看客户详细信息\" class=\"tablelink\">"+r.custom.customname+"</a></cite>\n" +
                "    </li>\n" +
                "    <li>\n" +
                "      <label>联系电话</label>\n" +
                "      <cite>"+r.custom.telephone+"</cite>\n" +
                "    </li>\n" +
                "    <li>\n" +
                "      <label>订购时间</label>\n" +
                "      <cite>"+getFormtTime(r.ordertime,false)+"</cite>\n" +
                "    </li>\n" +
                "    <li>\n" +
                "      <label>总金额</label>\n" +
                "       <cite>￥"+r.ordermoney+"</cite>\n" +
                "    </li>\n" +
                "    <li>\n" +
                "      <label>操作人</label>\n" +
                "      <cite>"+r.users1.uname+"</cite>\n" +
                "    </li>\n" +
                "    <li>\n" +
                "      <label>审核状态</label>\n" +
                "      <cite>"+n+"</cite>\n" +
                "    </li>\n" +
                "    <li>\n" +
                "      <label>审核意见</label>\n" +
                "      <cite>"+r.opinion+"</cite>\n" +
                "    </li>\n" +
                "    <li>\n" +
                "      <label>审核人</label>\n" +
                "      <cite>"+r.users2.uname+"</cite>\n" +
                "    </li>\n" +
                "    <li>\n" +
                "      <label>审核时间</label>\n" +
                "      <cite>"+getFormtTime(r.chectime,false)+"</cite>\n" +
                "    </li>"
            $(".forminfo").html(u)
            $.ajax({
                type: "post",
                url: "/orde/queryOneOrderDetails/"+r.orderid,
                data: {},
                dataType: "json",
                success: function (x) {
                    if (x!=null){
                        var t="<tr>\n" +
                            "          <th>序号</th>\n" +
                            "          <th>品牌</th>\n" +
                            "          <th>类型</th>\n" +
                            "          <th>型号</th>\n" +
                            "          <th>数量</th>\n" +
                            "          <th>单位</th>\n" +
                            "          <th>单价</th>\n" +
                            "          <th>金额</th>\n" +
                            "        </tr>"
                        for (var i=0;i<x.length;i++){
                            t+="<tr>\n" +
                                "          <td>"+x[i].detailsId+"</td>\n" +
                                "          <td>"+x[i].product.type.brand.brandName+"</td>\n" +
                                "          <td>"+x[i].product.type.typeName+"</td>\n" +
                                "          <td>"+x[i].product.productModel+"</td>\n" +
                                "          <td>"+x[i].purchaseNum+"</td>\n" +
                                "          <td>"+x[i].product.productUnit+"</td>\n" +
                                "          <td>"+x[i].proprice+"</td>\n" +
                                "          <td>"+x[i].prototal+"</td>\n" +
                                "        </tr>"
                        }
                        $(".tablelist").html(t)
                    }
                }
            })
        }
    }
})